package LC24;

import java.util.Arrays;

/**
 * 2352. 相等行列对
 *
 * @author zhangsan
 */
public class LC2352 {
    public static void main(String[] args) {
        int[][] ints = {{3,2,1},{1,7,6},{2,7,7}};
        System.out.println(equalPairs(ints));

    }

    public static int equalPairs(int[][] grid) {
        int num = 0;
        int len = grid.length;
        int[][] arrs = new int[len][len];
        for (int i = 0; i < len; i++) {
            for (int j = 0; j < len; j++) {
                arrs[i][j] = grid[j][i];
            }
        }

        for (int i = 0; i < len; i++) {
            for (int j = 0; j < len; j++) {
                int[] arr1 = grid[i];
                int[] arr2 = arrs[j];
                if (Arrays.equals(arr1, arr2)) {
                    num++;
                }
            }
        }

        return num;
    }
}
